package com.yuexun.beilunpatient.ui.question.presenter.impl;

import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.question.bean.PatientQuestionBean;
import com.yuexun.beilunpatient.ui.question.model.IQuestionModel;
import com.yuexun.beilunpatient.ui.question.presenter.IPatientQuestionPresenter;
import com.yuexun.beilunpatient.ui.question.ui.view.IPatientQuestionView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/8/23.
 */
public class PatientQuestionPresenter implements IPatientQuestionPresenter {

    private IPatientQuestionView view;
    private IQuestionModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public PatientQuestionPresenter(IQuestionModel model, IPatientQuestionView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void inquirePatientQuestionListPage(Map<String, String> praise) {
        model.inquirePatientQuestionListPage(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<PatientQuestionBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("查询提问失败");
                    }

                    @Override
                    public void onNext(BaseEntity<PatientQuestionBean> entity) {
                        view.showPatientQuestion(entity);
                    }
                });
    }
}
